//
//  PGNavigationController.m
//  全民债券
//  Created by yu on 15/10/26.
//  Copyright (c) 2015年 pg. All rights reserved.
//

#import "PGNavigationController.h"

@interface PGNavigationController ()

@end

@implementation PGNavigationController

+ (void)initialize
{
    //统一设置UINavigationBar
    UINavigationBar *bar = [UINavigationBar appearance];
//    
//    UIImage *image = [UIImage imageNamed:@"首页导航栏"];
//    [image stretchableImageWithLeftCapWidth:image.size.width * 0.5 topCapHeight:image.size.height * 0.5];
//    [bar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
    bar.barTintColor = [UIColor colorWithRed:38.0f/255.0f green:153.0f/255.0f blue:67.0f/255.0f alpha:1.0];
    bar.translucent = NO;
    [bar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor], NSFontAttributeName:[UIFont systemFontOfSize:20]}];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

//拦截导航控制器push进来的所有控制器
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.childViewControllers.count > 0) {//当viewController不是导航控制器的第一个控制器
        viewController.hidesBottomBarWhenPushed = YES;
        
//        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
//        [btn setTitle:@"<" forState:UIControlStateNormal];
//        [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//        [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
//        [btn sizeToFit];
//         btn.contentEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
//        [btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
//        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(back) image:@"fanghui_03" highImage:@"fanghui_03"];

    }
    
    [super pushViewController:viewController animated:animated];
}

//navigationItem.leftBarButtonItem的点击事件
- (void)back
{
    [self popViewControllerAnimated:YES];
}

@end
